package cn.edu.xjtu.android.emoji_warfare_android.util;

import android.util.Log;

/**
 * Gap<br>
 * 性能调试工具 Created by bill on 2017/11/28.
 */

public class Gap {

    private static String sTag = "Gap";
    private static long sLast;

    private String tag;
    private long last;

    static {
        sLast = System.currentTimeMillis();
    }

    public Gap() {
        this(sTag);
    }

    public Gap(String tag) {
        this.tag = tag;
        last = System.currentTimeMillis();
    }

    public static void log(String tag) {
        long now = System.currentTimeMillis();
        Log.d(tag, String.valueOf(now - sLast));
        sLast = now;
    }

    public static void log() {
        log(sTag);
    }

    public static void start() {
        sLast = System.currentTimeMillis();
    }

    public static void setStaticTag(String tag) {
        sTag = tag;
    }

    public void mlog(String tag) {
        long now = System.currentTimeMillis();
        Log.d(tag, String.valueOf(now - last));
        last = now;
    }

    public void mlog() {
        mlog(tag);
    }

    public void mstart() {
        last = System.currentTimeMillis();
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

}
